const formatTime = date => {
  const year = date.getFullYear();
  const month = date.getMonth() + 1;
  const day = date.getDate();
  const hour = date.getHours();
  const minute = date.getMinutes();
  const second = date.getSeconds();
  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
};

const format_time = mss => {
	
	    var days = parseInt(mss / (1000 * 60 * 60 * 24));
	    var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	    var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
	    var seconds = (mss % (1000 * 60)) / 1000;
	    return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
}

const formatNumber = n => {
  n = n.toString();
  return n[1] ? n : '0' + n;
};

module.exports = {
  formatTime: formatTime,
  format_time: format_time
};